<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        let music = {
            name:'孤勇者',
            auth:'陈奕迅',
            pulishDate:'2022-1-1'
        }
        // 如果不使用解构赋值  使用对象下的信息 每次都需要通过对象调属性的方式访问
        console.log(music.auth);
        // 1、解构赋值的语法  let {属性名称} = 对象
        // 就类似于 let auth = music.auth,let name = music.name
        // 一般 解构出来的变量名称 需要与对象下的属性名称保持一致
        let {auth,name} = music;
        console.log(auth,name);
        // 2、解构并且设置别名 
        // 等价于 let timer = music.pulishDate
        let {pulishDate:timer} = music;
        console.log(timer)
        // 3、多级解构
        let userInfo = {
            id:10001,
            name:'XXXX',
            className:{
                id:'2208',
                classRoom:'10教'
            }
        }
        // 等价于  let id = userInfo.id ; let classRoom = userInfo.className.classRoom 
       let {id,className:{classRoom}} = userInfo;
       console.log(classRoom,id)
</script>
</body>
</html>